﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
	<link href="js-console.css" rel="stylesheet" />
	<!-- 4. Sort 3 real values in descending order using nested if statements. -->
</head>
<body>
	<div id="js-console"></div>
	<script src="js-console.js"></script>
	<script>
		//Read input
		var first = prompt("Enter first number");
		var second = prompt("Enter second number");
		var third = prompt("Enter third number");

		if (!isNaN(first) && !isNaN(second) && !isNaN(third)) {
			first *= 1; second *= 1; third *= 1;	// make them real number

			// Write the input
			jsConsole.writeLine("The three numbers are: " + first + ", " + second + ", " + third);

			// Sorting
			if (first < second)
			{
				var swap = first;
				first = second;
				second = swap;
			}
		
			if (second < third)
			{
				var swap = third;
				third = second;
				second = swap;
			}

			if (first < second)
			{
				var swap = first;
				first = second;
				second = swap;
			}

			// Write result
			jsConsole.writeLine("Sorted numbers are: " + first + ", " + second + ", " + third);
		}
		else {
			jsConsole.writeLine("Wrong input.");
		}
	</script>
</body>
</html>
